
package org.springxrsk.modules.resource.rule.oss;

import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import org.springxrsk.core.log.exception.ServiceException;
import org.springxrsk.core.oss.OssTemplate;
import org.springxrsk.core.tool.utils.Func;
import org.springxrsk.modules.resource.rule.context.OssContext;
import org.springxrsk.modules.resource.pojo.entity.Oss;

import java.util.Map;

/**
 * OSS缓存读取校验
 *
 * @author
 */
@LiteflowComponent(id = "ossReadRule", name = "OSS缓存读取校验")
public class OssReadRule extends NodeComponent {
	@Override
	public void process() throws Exception {
		String tenantId = this.getRequestData();
		OssContext contextBean = this.getContextBean(OssContext.class);
		Map<String, Oss> ossPool = contextBean.getOssPool();
		Map<String, OssTemplate> templatePool = contextBean.getTemplatePool();
		Oss ossCached = ossPool.get(tenantId);
		OssTemplate template = templatePool.get(tenantId);
		if (Func.hasEmpty(template, ossCached)) {
			throw new ServiceException("OSS缓存读取失败!");
		}
	}
}
